package com.lkbaby.chain;

import java.util.ArrayList;
import java.util.List;

/**
 * 责任链
 */
public class HandlerChain {

	private List<Handler> handlerList = new ArrayList<>();

	public void addHandler(Handler handler) {
		this.handlerList.add(handler);
	}

	public void process(Request request) {
		for (Handler handler : handlerList) {
			Boolean process = handler.process(request);
			if (process != null) {
				return;
			}
		}
		System.out.println("Could not handle request: " + request);
	}

}
